function [out,outliers_Index] = my_rmoutliers(Input,Dim,opt)
% [out,index] = my_rmoutliers(Input,Dim,opt)
% ---------------------------------
% Description:
% 	rm outliers in 2D map
% Input:
% 	Input: Matrix, 2D 
% 	Dim: 0 = all
% 	opt: optional 
% 		Method:	mean;median;
% Output:
% 	out, Matrix 2D, outliers removed
% 	index, the linear index of outliers in matrix
%
% Note:
% 	Dim is reserved arguments for further development
	arguments
		Input
		Dim = 0
		opt.method = "median"
		opt.percentile = []
	end


	if ~isempty(opt.percentile)
		outliers_Index = isoutlier(Input(:),'percentile',opt.percentile);
	else
		outliers_Index = isoutlier(Input(:),opt.method);
	end

	out = Input;
	out(outliers_Index) = NaN;
end
